﻿using System;
using Zeus.Thunder.Core;

namespace SharpTrainer.Other
{
    class TimerTest : ITestCase
    {
        public void Run()
        {
            TimerDemo.Go();
        }
    }
}

internal static class TimerDemo
{
    public static void Go()
    {
        // Create a Timer object that knows to call our TimerCallback 
        // method once every 2000 milliseconds.
        var t = new System.Threading.Timer(TimerCallback, null, 0, 2000);

        // Wait for the user to hit <Enter>
        Console.ReadLine();

        // Refer to t after ReadLine (this gets optimized away)
        //t = null;

        // Refer to t after ReadLine (t will survive GCs until Dispose returns)
        //t.Dispose();
    }

    private static void TimerCallback(Object o)
    {
        // Display the date/time when this method got called.
        Console.WriteLine("In TimerCallback: " + DateTime.Now);

        // Force a garbage collection to occur for this demo.
        GC.Collect();
    }
}